package com.quanyan.place.web;

import com.quanyan.api.APIResponse;
import com.quanyan.api.enums.ApiResponseEnum;
import com.quanyan.place.entity.apireq.ReqPlaceGoodsCommonVo;
import com.quanyan.place.entity.apireq.ReqPlaceGoodsTypeVo;
import com.quanyan.place.entity.apireq.ReqPlaceGoodsVo;
import com.quanyan.place.entity.apireq.ReqSupplierVo;
import com.quanyan.place.wrapper.PlaceGoodsWrapper;
import com.quanyan.place.wrapper.PlaceOrderServiceWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * Created by yangyun on 2016/4/14.
 */

@RestController
@RequestMapping("/admin/api/place/goods")
public class PlaceGoodsController {

    @Autowired
    PlaceGoodsWrapper placeGoodsWrapper;
    @Autowired
    PlaceOrderServiceWrapper placeOrderServiceWrapper;
    /**
     * 商品列表
     * @param reqPlaceGoodsVo
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/getPlaceGoodsList",method = RequestMethod.POST)
    public APIResponse<?> getPlaceGoodsList(@RequestBody @Valid ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.getPlaceGoodsList(reqPlaceGoodsVo);
    }

    @RequestMapping(value="/getPlaceGoodsListNew",method = RequestMethod.POST)
    public APIResponse<?> getPlaceGoodsListNew(@RequestBody @Valid ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.getPlaceGoodsListNew(reqPlaceGoodsVo);
    }
    /**
     * 新增商品
     * @param reqPlaceGoodsVo
     * @param bindingResult
     * @return
     */
   /* @RequestMapping(value="/insertPlaceGoodsInfo",method = RequestMethod.POST)
    public APIResponse<?> insertPlaceGoodsInfo(@RequestBody @Valid ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        if (reqPlaceGoodsVo!=null){
            return placeGoodsWrapper.insertPlaceGoodsInfo(reqPlaceGoodsVo);
        }else{
            return APIResponse.returnFail("保存的数据为空");
        }
    }*/

    /**
     * 新增商品
     * @param reqPlaceGoodsVo
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/insertPlaceGoodsInfo",method = RequestMethod.POST)
    public APIResponse<?> insertPlaceGoodsInfo(@RequestBody @Valid ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        if (reqPlaceGoodsVo!=null){
            return placeGoodsWrapper.insertPlaceGoodsInfo(reqPlaceGoodsVo);
        }else{
            return APIResponse.returnFail("保存的数据为空");
        }
    }

    @RequestMapping(value="/insertPlaceGoodsInfoNew",method = RequestMethod.POST)
    public APIResponse<?> insertPlaceGoodsInfoNew(@RequestBody @Valid ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        if (reqPlaceGoodsVo!=null){
            return placeGoodsWrapper.insertPlaceGoodsInfoNew(reqPlaceGoodsVo);
        }else{
            return APIResponse.returnFail("保存的数据为空");
        }
    }

    /**
     * 更新商品
     * @param reqPlaceGoodsVo
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/updatePlaceGoodsInfo" ,method = RequestMethod.POST)
    public APIResponse<?>updatePlaceGoodsInfo(@RequestBody ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        return placeGoodsWrapper.updatePlaceGoodsInfo(reqPlaceGoodsVo);
    }

    @RequestMapping(value="/updatePlaceGoodsInfoNew" ,method = RequestMethod.POST)
    public APIResponse<?>updatePlaceGoodsInfoNew(@RequestBody ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        return placeGoodsWrapper.updatePlaceGoodsInfoNew(reqPlaceGoodsVo);
    }
    /**
     * 删除商品
     * @param reqPlaceGoodsVo
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/deletePlaceGoodsInfo",method = RequestMethod.POST)
    public APIResponse<?> deletePlaceGoodsInfo(@RequestBody ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        placeGoodsWrapper.deletePlaceGoodsInfo(reqPlaceGoodsVo);
        return APIResponse.returnSuccess();
    }

    /**
     * 导出商品信息
     * @param reqPlaceGoodsVo
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/exportPlaceGoodsInfo",method = RequestMethod.POST)
    public APIResponse<?> exportPlaceGoodsInfo(@RequestBody ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
       return placeGoodsWrapper.exportPlaceGoodsInfo(reqPlaceGoodsVo);
    }

    @RequestMapping(value="/exportPlaceGoodsInfoNew",method = RequestMethod.POST)
    public APIResponse<?> exportPlaceGoodsInfoNew(@RequestBody ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        return placeGoodsWrapper.exportPlaceGoodsInfoNew(reqPlaceGoodsVo);
    }

    /**
     * 导入商品信息
     * @param reqPlaceGoodsVo
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/importPlaceGoodsInfo",method = RequestMethod.POST)
    public APIResponse<?> importtPlaceGoodsInfo(@RequestBody ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        return placeGoodsWrapper.importPlaceGoodsInfo(reqPlaceGoodsVo);
    }

    /**
     * 新增商品类型
     * @param reqPlaceGoodsTypeVo
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/insertPlaceGoodsTypeData",method = RequestMethod.POST)
    public APIResponse<?> insertPlaceGoodsTypeData(@RequestBody ReqPlaceGoodsTypeVo reqPlaceGoodsTypeVo, BindingResult bindingResult){
        return placeGoodsWrapper.insertPlaceGoodsTypeData(reqPlaceGoodsTypeVo);
    }

    /**
     * 获取商品类型
     * @param reqPlaceGoodsTypeVo
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/getPlaceGoodsTypeData",method = RequestMethod.POST)
    public APIResponse<?> getPlaceGoodsTypeData(@RequestBody ReqPlaceGoodsTypeVo reqPlaceGoodsTypeVo,BindingResult bindingResult){
        return placeGoodsWrapper.getPlaceGoodsTypeData(reqPlaceGoodsTypeVo);
    }

    /**
     * 获取商品类型（分页）
     * @param reqPlaceGoodsTypeVo
     * @param bindingResult
     * @return
     */
  /*  @RequestMapping(value="/getPlaceGoodsTypeList",method = RequestMethod.POST)
    public APIResponse<?> getPlaceGoodsTypeList(@RequestBody ReqPlaceGoodsTypeVo reqPlaceGoodsTypeVo,BindingResult bindingResult){
        return placeGoodsWrapper.getPlaceGoodsTypeList(reqPlaceGoodsTypeVo);
    }*/

    /**
     * 获取商品类型（分页）
     * @param reqPlaceGoodsTypeVo
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/getPlaceGoodsTypeList",method = RequestMethod.POST)
    public APIResponse<?> getPlaceGoodsTypeList(@RequestBody ReqPlaceGoodsTypeVo reqPlaceGoodsTypeVo,BindingResult bindingResult){
        return placeGoodsWrapper.getPlaceGoodsTypeList(reqPlaceGoodsTypeVo);
    }

    /**
     * 更新商品类型
     * @param reqPlaceGoodsTypeVo
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/updatePlaceGoodsTypeData",method = RequestMethod.POST)
    public APIResponse<?> updatePlaceGoodsTypeData(@RequestBody ReqPlaceGoodsTypeVo reqPlaceGoodsTypeVo,BindingResult bindingResult){
            return  placeGoodsWrapper.updatePlaceGoodsTypeData(reqPlaceGoodsTypeVo);
    }

    /*@RequestMapping(value="/updatePlaceGoodsTypeDatassss",method = RequestMethod.POST)
    public APIResponse<?> updatePlaceGoodsTypeDatassss(@RequestBody ReqPlaceGoodsTypeVo reqPlaceGoodsTypeVo,BindingResult bindingResult){
        return  placeGoodsWrapper.updatePlaceGoodsTypeDatassss(reqPlaceGoodsTypeVo);
    }
*/
    /**
     * 提交商品订单 9
     * @param reqPlaceGoodsVo
     * @return
     */
    @RequestMapping(value="/submitGoodsOrder",method = RequestMethod.POST)
    public APIResponse<?> submitGoodsOrder(@RequestBody ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        APIResponse apiResponse=  placeGoodsWrapper.submitGoodsOrder(reqPlaceGoodsVo,placeOrderServiceWrapper);
        return apiResponse;
    }

    @RequestMapping(value="/goodsSaleIncomeReport",method = RequestMethod.POST)
    public APIResponse<?> goodsSaleIncomeReport(@RequestBody ReqPlaceGoodsVo reqPlaceGoodsVo){
        return  placeGoodsWrapper.goodsSaleIncomeReport(reqPlaceGoodsVo);
    }


    /**
     * 商品售卖会员卡消费获取用户所有相关会员卡
     */
    @RequestMapping(value="/goodsConsumeGetMemberCardList",method = RequestMethod.POST)
    public APIResponse<?> goodsConsumeGetMemberCardList(@RequestBody ReqPlaceGoodsVo reqPlaceGoodsVo){
        return  placeGoodsWrapper.goodsConsumeGetMemberCardList(reqPlaceGoodsVo);
    }



    /**
     * 库存录入记录
     * @param reqPlaceGoodsVo
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/insertInventoryRecord",method = RequestMethod.POST)
    public APIResponse<?> insertInventoryRecord(@RequestBody @Valid ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        if (reqPlaceGoodsVo!=null){
            return placeGoodsWrapper.insertInventoryRecord(reqPlaceGoodsVo);
        }else{
            return APIResponse.returnFail("保存的数据为空");
        }
    }

    /**
     * 库存记录列表
     * @param reqPlaceGoodsVo
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/inventoryRecordList",method = RequestMethod.POST)
    public APIResponse<?> inventoryRecordList(@RequestBody @Valid ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        if (reqPlaceGoodsVo!=null){
            return placeGoodsWrapper.inventoryRecordList(reqPlaceGoodsVo);
        }else{
            return APIResponse.returnFail("保存的数据为空");
        }
    }


    @RequestMapping(value="/getOneLevel",method = RequestMethod.POST)
    public APIResponse<?> getOneLevel(@RequestBody @Valid ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        if (reqPlaceGoodsVo!=null){
            return placeGoodsWrapper.getOneLevel(reqPlaceGoodsVo.getDataKey());
        }else{
            return APIResponse.returnFail("非法请求");
        }
    }


    @RequestMapping(value="/getTypeByParenLevel",method = RequestMethod.POST)
    public APIResponse<?> getTypeByParenLevel(@RequestBody @Valid ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult) {
        if (reqPlaceGoodsVo != null) {
            return placeGoodsWrapper.getTypeByParenLevel(reqPlaceGoodsVo);
        } else {
            return APIResponse.returnFail("非法请求");
        }
    }
    /**
     * 商品销售明细
     * @return
     */
    @RequestMapping(value="/getGoodsDetail",method = RequestMethod.POST)
    public APIResponse<?> getGoodsDetail(@RequestBody @Valid Map<String,Object> map,BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            return  APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.getGoodsDetail(map);

    }

    /**
     * 商品销售明细导出
     * @return
     */
    @RequestMapping(value="/getGoodsDetailExport",method = RequestMethod.POST)
    public APIResponse<?> getGoodsDetailExport(@RequestBody @Valid Map<String,Object> map,BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            return  APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.getGoodsDetailExport(map);
    }

    /**
     * 供应商录入
     * @return
     */
    @RequestMapping(value="/saveSupplierInfo",method = RequestMethod.POST)
    public APIResponse<?> saveSupplierInfo(@RequestBody ReqSupplierVo reqSupplierVo, BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            return  APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.saveSupplierInfo(reqSupplierVo);
    }

    /**
     * 多种经营供应商列表
     * @param reqSupplierVo
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/getSupplierInfoList",method = RequestMethod.POST)
    public APIResponse<?> getSupplierInfoList(@RequestBody @Valid ReqSupplierVo reqSupplierVo,BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.getSupplierInfoList(reqSupplierVo);
    }

    /**
     * 多种经营供应商删除
     * @return
     */
    @RequestMapping(value="/deleteSupplierInfo",method = RequestMethod.POST)
    public APIResponse<?> deleteSupplierInfo(@RequestBody ReqSupplierVo reqSupplierVo, BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            return  APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.deleteSupplierInfo(reqSupplierVo);
    }

    /**
     * 编辑多种经营供应商
     * @return
     */
    @RequestMapping(value="/updateSupplierInfo",method = RequestMethod.POST)
    public APIResponse<?> updateSupplierInfo(@RequestBody ReqSupplierVo reqSupplierVo, BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            return  APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.updateSupplierInfo(reqSupplierVo);
    }

    /**
     * 编辑多种经营供应商
     * @return
     */
    @RequestMapping(value="/getSupplierNameByCityId",method = RequestMethod.POST)
    public APIResponse<?> getSupplierNameByCityId(@RequestBody ReqSupplierVo reqSupplierVo, BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            return  APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.getSupplierNameByCityId(reqSupplierVo.getCityId());
    }

    /**
     * 盘点库存
     * @return
     */
    @RequestMapping(value="/checkGoodsInventory",method = RequestMethod.POST)
    public APIResponse<?> checkGoodsInventory(@RequestBody ReqPlaceGoodsVo reqPlaceGoodsVo, BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
       return placeGoodsWrapper.checkGoodsInventory(reqPlaceGoodsVo);
    }

    /**
     * 商品交易记录
     * @return
     */
    @RequestMapping(value="/goodsTradeRecord",method = RequestMethod.POST)
    public APIResponse<?> goodsTradeRecord(@RequestBody ReqPlaceGoodsVo reqPlaceGoodsVo, BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            return  APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        APIResponse response= placeGoodsWrapper.goodsTradeRecord(reqPlaceGoodsVo);
        return response;

    }



/**
     * 商品销售统计  --按商品编号
     *
     * @param map
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/getGoodsStatisticsByGoodsId",method = RequestMethod.POST)
    public APIResponse<?> getGoodsStatisticsByGoodsId(@RequestBody @Valid Map<String,Object> map,BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            return  APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.getGoodsStatisticsByGoodsId(map);
    }

    /**
     * 商品销售统计  --按商品编号(导出)
     * @param map
     * @param bindingResult
     * @return
     */
    @RequestMapping(value = "/getGoodsStatisticsByGoodsIdExport",method = RequestMethod.POST)
    public APIResponse<?> getTicketStatisticsByTicketCodeExport(@RequestBody @Valid Map<String, Object> map,
                                                                BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        map.put("pageNum",null);
        map.put("pageSize",null);
        return placeGoodsWrapper.getGoodsStatisticsByGoodsIdExport(map);
    }

    /**
     * 商品销售统计  --按一级目录
     *
     * @param map
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/getGoodsStatisticsByOneLevel",method = RequestMethod.POST)
    public APIResponse<?> getGoodsStatisticsByOneLevel(@RequestBody @Valid Map<String,Object> map,BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            return  APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.getGoodsStatisticsByOneLevel(map);
    }

    /**
     * 商品销售统计  --按一级目录(导出)
     * @param map
     * @param bindingResult
     * @return
     */
    @RequestMapping(value = "/getGoodsStatisticsByOneLevelExport",method = RequestMethod.POST)
    public APIResponse<?> getGoodsStatisticsByOneLevelExport(@RequestBody @Valid Map<String, Object> map,
                                                                BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        map.put("pageNum",null);
        map.put("pageSize",null);
        return placeGoodsWrapper.getGoodsStatisticsByOneLevelExport(map);
    }

    /**
     * 商品销售统计  --按二级目录
     *
     * @param map
     * @param bindingResult
     * @return
     */
    @RequestMapping(value="/getGoodsStatisticsByTwoLevel",method = RequestMethod.POST)
    public APIResponse<?> getGoodsStatisticsByTwoLevel(@RequestBody @Valid Map<String,Object> map,BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            return  APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.getGoodsStatisticsByTwoLevel(map);
    }

    /**
     * 商品销售统计  --按二级目录(导出)
     * @param map
     * @param bindingResult
     * @return
     */
    @RequestMapping(value = "/getGoodsStatisticsByTwoLevelExport",method = RequestMethod.POST)
    public APIResponse<?> getGoodsStatisticsByTwoLevelExport(@RequestBody @Valid Map<String, Object> map,
                                                             BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        map.put("pageNum",null);
        map.put("pageSize",null);
        return placeGoodsWrapper.getGoodsStatisticsByTwoLevelExport(map);
    }

    /**
     * 商品销售统计  --按散客会员
     * @param map
     * @param bindingResult
     * @return
     */
    @RequestMapping(value = "/getGoodsStatisticsByMember",method = RequestMethod.POST)
    public APIResponse<?> getGoodsStatisticsByMember(@RequestBody @Valid Map<String, Object> map,
                                                             BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.getGoodsStatisticsByMember(map);
    }

    /**
     * 商品销售统计  --按散客会员(导出)
     * @param map
     * @param bindingResult
     * @return
     */
    @RequestMapping(value = "/getGoodsStatisticsByMemberExport",method = RequestMethod.POST)
    public APIResponse<?> getGoodsStatisticsByMemberExport(@RequestBody @Valid Map<String, Object> map,
                                                     BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.getGoodsStatisticsByMember(map);
    }

    @RequestMapping(value="/insertGoodsOperateRecord",method = RequestMethod.POST)
    public APIResponse<?> insertGoodsOperateRecord(@RequestBody ReqPlaceGoodsVo reqPlaceGoodsVo, BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            return  APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        APIResponse response= placeGoodsWrapper.insertGoodsOperateRecord(reqPlaceGoodsVo);
        return response;
    }


    @RequestMapping(value="/getGoodsTypeAndGoodsCount",method = RequestMethod.POST)
    public APIResponse<?> getGoodsTypeAndGoodsCount(@RequestBody ReqPlaceGoodsVo reqPlaceGoodsVo, BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            return  APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        APIResponse response= placeGoodsWrapper.getGoodsTypeAndGoodsCount(reqPlaceGoodsVo);
        return response;
    }

    /**
     * 统一商品库（新增商品类型）
     * @param map
     * @return
     */
    @RequestMapping(value="/insertGoodsCommonType",method = RequestMethod.POST)
    public APIResponse<?> insertGoodsCommonType(@RequestBody @Valid Map<String,Object> map, BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.insertGoodsCommonType(map);
    }

    /**
     * 统一商品库（更新商品类型）
     * @param map
     * @return
     */
    @RequestMapping(value="/updateGoodsCommonType",method = RequestMethod.POST)
    public APIResponse<?> updateGoodsCommonType(@RequestBody @Valid Map<String,Object> map, BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.updateGoodsCommonType(map);
    }

    /**
     * 统一商品库（商品类型列表）
     * @param map
     * @return
     */
    @RequestMapping(value="/goodsTypeCommonList",method = RequestMethod.POST)
    public APIResponse<?> goodsTypeCommonList(@RequestBody @Valid Map<String,Object> map, BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.goodsTypeCommonList(map);
    }

    /**
     * 统一商品库信息（新增商品）
     * @param reqPlaceGoodsCommonVo
     * @param bindingResult
     * @return
     */

    @RequestMapping(value="/insertGoodsCommon",method = RequestMethod.POST)
    public APIResponse<?> insertGoodsCommon(@RequestBody @Valid ReqPlaceGoodsCommonVo reqPlaceGoodsCommonVo, BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.insertGoodsCommon(reqPlaceGoodsCommonVo);
    }

    /**
     * 统一商品库信息（更新商品）
     * @param reqPlaceGoodsCommonVo
     * @param bindingResult
     * @return
     */

    @RequestMapping(value="/updateGoodsCommon",method = RequestMethod.POST)
    public APIResponse<?> updateGoodsCommon(@RequestBody @Valid ReqPlaceGoodsCommonVo reqPlaceGoodsCommonVo, BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.updateGoodsCommon(reqPlaceGoodsCommonVo);
    }

    /**
     * 统一商品库信息（商品列表）
     * @param map
     * @return
     */
    @RequestMapping(value="/goodsCommonList",method = RequestMethod.POST)
    public APIResponse<?> goodsCommonList(@RequestBody @Valid Map<String,Object> map, BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        return placeGoodsWrapper.goodsCommonList(map);
    }

    @RequestMapping(value="/getTypeCommonByParentLevel",method = RequestMethod.POST)
    public APIResponse<?> getTypeCommonByParentLevel(@RequestBody @Valid Map<String,Object> map, BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        if (map != null) {
            return placeGoodsWrapper.getTypeCommonByParentLevel(map);
        } else {
            return APIResponse.returnFail("非法请求");
        }
    }

    /**
     * 批量入库
     * @param reqPlaceGoodsVo
     * @param bindingResult
     * @return
     */

    @RequestMapping(value="/insertInventoryRecordBatch",method = RequestMethod.POST)
    public APIResponse<?> insertInventoryRecordBatch(@RequestBody @Valid ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        if (reqPlaceGoodsVo!=null){
            return placeGoodsWrapper.insertInventoryRecordBatch(reqPlaceGoodsVo);
        }else{
            return APIResponse.returnFail("保存的数据为空");
        }
    }

    /**
     * 批量盘点库存
     * @param reqPlaceGoodsVo
     * @param bindingResult
     * @return
     */

    @RequestMapping(value="/checkGoodsInventoryBatch",method = RequestMethod.POST)
    public APIResponse<?> checkGoodsInventoryBatch(@RequestBody @Valid ReqPlaceGoodsVo reqPlaceGoodsVo,BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        if (reqPlaceGoodsVo!=null){
            return placeGoodsWrapper.checkGoodsInventoryBatch(reqPlaceGoodsVo);
        }else{
            return APIResponse.returnFail("保存的数据为空");
        }
    }

    /**
     * 上下架
     * @param reqPlaceGoodVo
     * @return
     */

    @RequestMapping(value="/updownGoods",method = RequestMethod.POST)
    public APIResponse<?> updownGoods(@RequestBody @Valid ReqPlaceGoodsVo reqPlaceGoodVo,BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        if (reqPlaceGoodVo!=null){
            return placeGoodsWrapper.updownGoods(reqPlaceGoodVo);
        }else{
            return APIResponse.returnFail("上下架失败");
        }
    }

    /**
     * 根据商品条码获取商品
     * @param reqPlaceGoodVo
     * @return
     */

    @RequestMapping(value="/getGoodsInfoByBarCode",method = RequestMethod.POST)
    public APIResponse<?> getGoodsInfoByBarCode(@RequestBody @Valid ReqPlaceGoodsVo reqPlaceGoodVo,BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        if (reqPlaceGoodVo!=null){
            return placeGoodsWrapper.getGoodsInfoByBarCode(reqPlaceGoodVo);
        }else{
            return APIResponse.returnFail("上下架失败");
        }
    }

    /**
     * 新商品列表增加商品，若若已添加则返回标志
     * @param map
     * @return
     */

    @RequestMapping(value="/insertGoodsAndList",method = RequestMethod.POST)
    public APIResponse<?> insertGoodsAndList(@RequestBody @Valid Map<String,Object> map,BindingResult bindingResult){
        if (bindingResult.hasErrors()) {
            return APIResponse.returnFail(ApiResponseEnum.PARAMETER_INVALID);
        }
        if (map!=null){
            return placeGoodsWrapper.insertGoodsAndList(map);
        }else{
            return APIResponse.returnFail("获取统一商品列表失败");
        }
    }
}
